package com.java.demo;

import com.java.demo.mode.ArticleInfo;
import org.springframework.context.annotation.Bean;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: ws
 * Date: 2023-07-19
 * Time: 14:07
 */

@Order(1)
@Component
public class Articles {
//    @Bean默认的是方法名
//    @Bean("aaa")//在自定义后，默认的就失效了
//    @Bean(name = "aaa")
//    @Bean(value = "aaa")


//    @Bean(value = {"aaa", "bbb", "article"})//支持多个名称
    //将当前方法返回的对象存储到IoC容器,必须配合五大类使用（减少搜索）
    @Bean(name = {"article", "aaa"})
    public ArticleInfo getArt() {
        //伪代码
        ArticleInfo articleInfo = new ArticleInfo();
        articleInfo.setAid(1);
        articleInfo.setTitle("今天周几");
        articleInfo.setContent("今天周一");
        articleInfo.setCreatetime(LocalDateTime.now());
        return articleInfo;
    }
}
